package com.hospital.controller;

import com.hospital.entity.Dept;
import com.hospital.service.DeptService;
import com.hospital.vo.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author coder_zzm
 * @date 2022/6/14 22:17
 */
@Slf4j
@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private DeptService deptService;

    /**
     * 两张表连接查询，主数据显示在左边
     * 这是一对多关系查询
     * @return 多条记录
     */
    @GetMapping("/getDeptAll")
    public Response getDeptAll() {
        log.info("控制层开始查询所有部门员工信息...");
        List<Dept> deptList = deptService.getDeptAll();
        return new Response(200, "success", deptList);
    }
}
